﻿<%@ Page Title="Students" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminMaster.master"
    Inherits="System.Web.Mvc.ViewPage<Eacademy.Domain.Models.StudentListViewModel>" %>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $(".subject a").click(function () {
                $(this).siblings(".mentors").slideToggle();
                return false;
            });
            $(".delete-student-link").live("click", function (event) {
                event.preventDefault();
                var $link = $(this);
                $("#dialog-confirm").dialog({
                    resizable: false,
                    height: 120,
                    modal: true,
                    draggable: false,
                    buttons: {
                        "Continue": function () {
                            $(this).dialog("close");
                            $.post($link.attr("href"), null, reloadPage);
                        },
                        Cancel: function () {
                            $(this).dialog("close");
                        }
                    }
                });
            })
        });

        function reloadPage() { location.reload(true); }

    </script>
    <style type="text/css">
        .mentors
        {
            height: 100px;
            width: 400px;
            display: none;
            border: 1px solid black;
        }
    </style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Students
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3>
        Student List</h3>
    <input type="button" value="Add Student" onclick="window.open('/admin/students/add/','_self')" class="button-style"/>
    <br />
    <br />
    <%=Html.Grid(Model.StudentList).Columns(column =>
      {
          column.For(x => x.FirstName).Sortable(true);
          column.For(x => x.MiddleName).Sortable(true);
          column.For(x => x.LastName).Sortable(true);
          column.For(x => x.StudentNumber).Sortable(true);
          column.For(x => Html.ActionLink("Edit", "Edit", new { id = x.StudentId }));
          column.For(x => Html.ActionLink("Delete", "Delete", new { id = x.StudentId }, new { @class = "delete-student-link" }));          
      }).Sort(Model.GridSortOptions)
            .Attributes(@id => "grid-style" , cellspacing => "0",cellpadding => "0")
            .Empty("No students")%>
    <div class="event-paging">
        <div class="pager">
            <% if (Model.StudentList.TotalItemCount > Model.StudentList.PageSize)
               {%>
            <%= Html.Pager(Model.StudentList.PageSize, Model.StudentList.PageNumber, Model.StudentList.TotalItemCount)%>
            <%} %>
        </div>
    </div>
    <div id="dialog-confirm" title="Delete this student?" style="display: none;">
        <p>
            Are you sure you want to delete this student?</p>
    </div>
</asp:Content>
